package com.samphanie.dries.security.authentication;

import com.samphanie.dries.config.MySecurityConfig;
import com.samphanie.dries.security.filter.RestAuthenticationFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.BeanIds;
import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.DefaultSecurityFilterChain;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Description:
 * @Author ZSY
 * @createTime 2021/2/25 11:08
 */
//@Component("restAuthSecurityConfig")
//public class RestAuthSecurityConfig extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> {
//
//    @Resource
//    AuthenticationSuccessHandler restAuthenticationSuccessHandler;
//    @Resource
//    AuthenticationFailureHandler restAuthenticationFailureHandler;
//    @Resource
//    AuthenticationManager authenticationManager;
//
//    @Override
//    public void configure(HttpSecurity http) {
//
//        RestAuthenticationFilter filter = new RestAuthenticationFilter();
//        filter.setAuthenticationSuccessHandler(restAuthenticationSuccessHandler);
//        filter.setAuthenticationFailureHandler(restAuthenticationFailureHandler);
//        filter.setAuthenticationManager(authenticationManager);
//        filter.setFilterProcessesUrl("/authorize/login");
//
//        http.addFilterAt(filter, UsernamePasswordAuthenticationFilter.class);
//    }
//
//}
